﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace Utility
{
	// Token: 0x02000656 RID: 1622
	public static class String
	{
		// Token: 0x0600268A RID: 9866 RVA: 0x00148078 File Offset: 0x00146278
		public static string RemoveExtension(this string self)
		{
			return self.Substring(0, self.LastIndexOf("."));
		}

		// Token: 0x0600268B RID: 9867 RVA: 0x0014808C File Offset: 0x0014628C
		public static string SetExtension(this string self, string extension)
		{
			return self.Substring(0, self.LastIndexOf(".")) + "." + extension;
		}

		// Token: 0x0600268C RID: 9868 RVA: 0x001480AC File Offset: 0x001462AC
		public static string RemoveNewLine(this string self)
		{
			return self.Replace("\r", string.Empty).Replace("\n", string.Empty);
		}

		// Token: 0x0600268D RID: 9869 RVA: 0x001480D0 File Offset: 0x001462D0
		public static bool Compare(this string self, string str, bool ignoreCase = false)
		{
			return string.Compare(self, str, ignoreCase) == 0;
		}

		// Token: 0x0600268E RID: 9870 RVA: 0x001480E0 File Offset: 0x001462E0
		public static bool Compare(this string self, string str, StringComparison comparison)
		{
			return string.Compare(self, str, comparison) == 0;
		}

		// Token: 0x0600268F RID: 9871 RVA: 0x001480F0 File Offset: 0x001462F0
		public static bool CompareParts(this string self, string str, bool ignoreCase = false)
		{
			return ignoreCase ? (self.IndexOf(str, StringComparison.OrdinalIgnoreCase) != -1) : (self.IndexOf(str) != -1);
		}

		// Token: 0x06002690 RID: 9872 RVA: 0x00148118 File Offset: 0x00146318
		public static bool CompareParts(this string self, string str, StringComparison comparison)
		{
			return self.IndexOf(str, comparison) != -1;
		}

		// Token: 0x06002691 RID: 9873 RVA: 0x00148128 File Offset: 0x00146328
		public static string[] LastStringEmptyRemove(this string[] self)
		{
			int num = self.Length;
			while (--num >= 0 && self[num].IsNullOrEmpty())
			{
			}
			string[] array = new string[++num];
			Array.Copy(self, 0, array, 0, num);
			return array;
		}

		// Token: 0x06002692 RID: 9874 RVA: 0x0014816C File Offset: 0x0014636C
		public static List<string> LastStringEmptyRemove(this List<string> self)
		{
			int num = self.Count;
			while (--num >= 0 && self[num].IsNullOrEmpty())
			{
			}
			return self.GetRange(0, num + 1);
		}

		// Token: 0x06002693 RID: 9875 RVA: 0x001481AC File Offset: 0x001463AC
		public static string[] LastStringEmptySpaceRemove(this string[] self)
		{
			int num = self.Length;
			while (--num >= 0 && self[num].IsNullOrWhiteSpace())
			{
			}
			string[] array = new string[++num];
			Array.Copy(self, 0, array, 0, num);
			return array;
		}

		// Token: 0x06002694 RID: 9876 RVA: 0x001481F0 File Offset: 0x001463F0
		public static List<string> LastStringEmptySpaceRemove(this List<string> self)
		{
			int num = self.Count;
			while (--num >= 0 && self[num].IsNullOrWhiteSpace())
			{
			}
			return self.GetRange(0, num + 1);
		}

		// Token: 0x06002695 RID: 9877 RVA: 0x00148230 File Offset: 0x00146430
		public static string Coloring(this string self, string color)
		{
			return string.Format("<color={0}>{1}</color>", color, self);
		}

		// Token: 0x06002696 RID: 9878 RVA: 0x00148240 File Offset: 0x00146440
		public static string Size(this string self, int size)
		{
			return string.Format("<size={0}>{1}</size>", size, self);
		}

		// Token: 0x06002697 RID: 9879 RVA: 0x00148254 File Offset: 0x00146454
		public static string Bold(this string self)
		{
			return string.Format("<b>{0}</b>", self);
		}

		// Token: 0x06002698 RID: 9880 RVA: 0x00148264 File Offset: 0x00146464
		public static string Italic(this string self)
		{
			return string.Format("<i>{0}</i>", self);
		}

		// Token: 0x06002699 RID: 9881 RVA: 0x00148274 File Offset: 0x00146474
		public static Color GetColor(this string self)
		{
			Color result = Color.clear;
			if (self.IsNullOrEmpty())
			{
				return result;
			}
			string[] array = self.Split(new char[]
			{
				','
			});
			Color color2;
			if (array.Length >= 3)
			{
				int num = 0;
				Color color;
				float.TryParse(array.SafeGet(num++), out color.r);
				float.TryParse(array.SafeGet(num++), out color.g);
				float.TryParse(array.SafeGet(num++), out color.b);
				float.TryParse(array.SafeGet(num++), out color.a);
				for (int i = 0; i < num; i++)
				{
					if (color[i] > 1f)
					{
						color[i] = Mathf.InverseLerp(0f, 255f, color[i]);
					}
				}
				result = color;
			}
			else if (ColorUtility.TryParseHtmlString(self, out color2))
			{
				result = color2;
			}
			return result;
		}

		// Token: 0x0600269A RID: 9882 RVA: 0x00148374 File Offset: 0x00146574
		public static Vector3 GetVector3(this string self)
		{
			string[] array = self.Replace("(", string.Empty).Replace(")", string.Empty).Replace(" ", string.Empty).Split(new char[]
			{
				','
			});
			int num = 0;
			return new Vector3(float.Parse(array[num++]), float.Parse(array[num++]), float.Parse(array[num++]));
		}

		// Token: 0x0600269B RID: 9883 RVA: 0x001483EC File Offset: 0x001465EC
		public static string RemoveAtLast(this string self, string value)
		{
			return self.Remove(self.LastIndexOf(value), value.Length);
		}
	}
}
